#include "Jerasure-1.2A/cauchy.h"
#include "Jerasure-1.2A/jerasure.h"
#include <stdlib.h>
#define K 4
#define M 2
#define W 8
#define CANARY_SIZE 16

char **encode(char *data, unsigned long size, char **data_ptrs)
{
  char *code, **code_ptrs;
  int i, j;
  int *matrix;//coding part of the matrix

  //malloc a place to store the coding data and set the ptrs to the disks
  code_ptrs = malloc(sizeof(char *)*2);
  code = malloc(size*M);
  for(i=0; i < M; i++)
    code_ptrs[i] = code + size*i;

  matrix = cauchy_original_coding_matrix(K, M, W);
  //jerasure_matrix_encode(K, M, W, matrix, data_ptrs, code_ptrs, size);
  for(i=0; i < 2; i++)
    for(j=0; j < 4; j++)
      galois_w08_region_multiply(data_ptrs[j], matrix[i*K+j], size, code_ptrs[i], j);
  return code_ptrs;
}
